package com.dszy.service;

import com.dszy.dao.ClazzDao;
import com.dszy.entity.Clazz;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ClazzServiceImpl implements ClazzService {
    @Resource
    private ClazzDao clazzDao;
    @Override
    public List<Clazz> queryAll(Clazz clazz) {
        return clazzDao.queryAll(clazz);
    }

    @Override
    public long count() {
        return clazzDao.count();
    }

    @Override
    public Clazz queryById(int clazzId) {
        return clazzDao.queryById(clazzId);
    }

    @Override
    public int insert(Clazz clazz) {
        try {
            int num = clazzDao.insert(clazz);
            return num;
        } catch (Exception e) {
            e.printStackTrace();
//            throw new RuntimeException(e);
            return 0;
        }
    }

    @Override
    public int insertBatch(List<Clazz> clazzList) {
        try {
            return clazzDao.insertBatch(clazzList);
        } catch (Exception e) {
            e.printStackTrace();
//            throw new RuntimeException(e);
            return 0;
        }
    }

    @Override
    public int insertOrUpdateBatch(List<Clazz> clazzList) {
        try {
            return clazzDao.insertOrUpdateBatch(clazzList);
        } catch (Exception e) {
            e.printStackTrace();
//            throw new RuntimeException(e);
            return 0;
        }
    }

    @Override
    public int update(Clazz clazz) {
        try {
            return clazzDao.update(clazz);
        } catch (Exception e) {
            e.printStackTrace();
//            throw new RuntimeException(e);
            return 0;
        }
    }

    @Override
    public int deleteById(int clazzId) {
        try {
            return clazzDao.deleteById(clazzId);
        } catch (Exception e) {
            e.printStackTrace();
//            throw new RuntimeException(e);
            return 0;
        }
    }
}
